home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / ServerAdmin.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  4.9 KB  |  136 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import java.util.Vector;
  7. import symjava.sql.SQLException;
  8.  
  9. public class ServerAdmin extends Requester {
  10.    // $FF: renamed from: _v java.util.Vector
  11.    Vector field_0;
  12.    int _mode;
  13.    NetString _reqStr;
  14.  
  15.    public ServerAdmin(ClientSession sess) {
  16.       super(sess);
  17.    }
  18.  
  19.    public Vector ping(String echo, int reps) throws SQLException {
  20.       this.field_0 = null;
  21.       this._mode = 0;
  22.       this._reqStr = new NetString("admin" + super._reqDelim + "ping" + super._reqDelim + echo + super._reqDelim + reps);
  23.       ((Requester)this).execute();
  24.       if (this.field_0 == null) {
  25.          throw new SQLException("Server ping failed.");
  26.       } else {
  27.          return this.field_0;
  28.       }
  29.    }
  30.  
  31.    public Vector getConnectList() throws SQLException {
  32.       this.field_0 = null;
  33.       this._mode = 1;
  34.       this._reqStr = new NetString("admin" + super._reqDelim + "getConnectList");
  35.       ((Requester)this).execute();
  36.       if (this.field_0 == null) {
  37.          throw new SQLException("Error getting server connection list.");
  38.       } else {
  39.          return this.field_0;
  40.       }
  41.    }
  42.  
  43.    public Vector getConnectDetails(int connectionID) throws SQLException {
  44.       this.field_0 = null;
  45.       this._mode = 2;
  46.       this._reqStr = new NetString("admin" + super._reqDelim + "getConnectDetails" + super._reqDelim + connectionID);
  47.       ((Requester)this).execute();
  48.       if (this.field_0 == null) {
  49.          throw new SQLException("Error getting Connection details.");
  50.       } else {
  51.          return this.field_0;
  52.       }
  53.    }
  54.  
  55.    public Vector getServerStats() throws SQLException {
  56.       this.field_0 = null;
  57.       this._mode = 3;
  58.       this._reqStr = new NetString("admin" + super._reqDelim + "getSrvStats");
  59.       ((Requester)this).execute();
  60.       if (this.field_0 == null) {
  61.          throw new SQLException("Error getting server statistics.");
  62.       } else {
  63.          return this.field_0;
  64.       }
  65.    }
  66.  
  67.    public void accept(boolean on) throws SQLException {
  68.       this._mode = 4;
  69.       String s = new String(on ? "yes" : "no");
  70.       this._reqStr = new NetString("admin" + super._reqDelim + "accept" + super._reqDelim + s);
  71.       ((Requester)this).execute();
  72.    }
  73.  
  74.    public ServerConfig getConfig() throws SQLException {
  75.       this.field_0 = null;
  76.       this._mode = 5;
  77.       this._reqStr = new NetString("admin,getConfig");
  78.       ((Requester)this).execute();
  79.       if (this.field_0 != null && this.field_0.size() >= 6) {
  80.          ServerConfig sc = new ServerConfig();
  81.          sc._bAllowRemoteAdmin = ((String)this.field_0.elementAt(0)).equals("true");
  82.          sc._bAllowDebug = ((String)this.field_0.elementAt(1)).equals("true");
  83.          sc._traceRequests = ((String)this.field_0.elementAt(2)).equals("true");
  84.          sc._traceObjects = ((String)this.field_0.elementAt(3)).equals("true");
  85.          sc._traceBytesRead = ((String)this.field_0.elementAt(4)).equals("true");
  86.          sc._traceBytesWritten = ((String)this.field_0.elementAt(5)).equals("true");
  87.          return sc;
  88.       } else {
  89.          throw new SQLException("Error getting config.");
  90.       }
  91.    }
  92.  
  93.    public void setConfig(ServerConfig sc) throws SQLException {
  94.       this._mode = 4;
  95.       this._reqStr = new NetString("admin,setConfig," + sc._traceRequests + super._reqDelim + sc._traceObjects + super._reqDelim + sc._traceBytesRead + super._reqDelim + sc._traceBytesWritten);
  96.       ((Requester)this).execute();
  97.    }
  98.  
  99.    public Vector trace(int connectionID) throws SQLException {
  100.       this.field_0 = null;
  101.       this._mode = 5;
  102.       this._reqStr = new NetString("admin" + super._reqDelim + "trace" + super._reqDelim + connectionID);
  103.       ((Requester)this).execute();
  104.       if (this.field_0 == null) {
  105.          throw new SQLException("Error tracing connection.");
  106.       } else {
  107.          return this.field_0;
  108.       }
  109.    }
  110.  
  111.    public void debug(String request) throws SQLException {
  112.       this._mode = 6;
  113.       this._reqStr = new NetString("debug," + request);
  114.       ((Requester)this).execute();
  115.    }
  116.  
  117.    public void kill(int connectionID) throws SQLException {
  118.       this._mode = 6;
  119.       this._reqStr = new NetString("admin" + super._reqDelim + "kill" + super._reqDelim + connectionID);
  120.       ((Requester)this).execute();
  121.    }
  122.  
  123.    protected void readResults(DataInputStream in) throws IOException, ErrorException, SQLException {
  124.       ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  125.       if ((this._mode == 0 || this._mode == 1 || this._mode == 2 || this._mode == 3 || this._mode == 5) && obj.getType() == 54) {
  126.          this.field_0 = ((ServerList)obj).toStringVector();
  127.       } else if (this._mode != 4 && this._mode != 6 || obj.getType() != 51) {
  128.          ((Requester)this).onObjectError(obj);
  129.       }
  130.    }
  131.  
  132.    protected void writeRequest(DataOutputStream out) throws IOException {
  133.       this._reqStr.write(out);
  134.    }
  135. }
  136.